package Ventanas;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.UIManager;

import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import javax.swing.JTextPane;
import java.awt.Insets;
import java.awt.SystemColor;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class VAviso extends JDialog {
	
	private JTextPane textoAviso;
	private JButton boton;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VAviso dialog = new VAviso("Prueba","Pues va a ser que si");
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public VAviso(String titulo, String descripcion) {
		try
		{
		   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
		initialize(titulo, descripcion);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	}
	
	private void initialize(String titulo, String descripcion)
	{
		setBounds(100, 100, 320, 200);
		setTitle(titulo);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
		getContentPane().setLayout(gridBagLayout);
		
		textoAviso = new JTextPane();
		textoAviso.setText(descripcion);
		textoAviso.setEditable(false);
		textoAviso.setBackground(SystemColor.menu);
		GridBagConstraints gbc_textPane = new GridBagConstraints();
		gbc_textPane.insets = new Insets(5, 5, 5, 5);
		gbc_textPane.fill = GridBagConstraints.BOTH;
		gbc_textPane.gridx = 0;
		gbc_textPane.gridy = 0;
		getContentPane().add(textoAviso, gbc_textPane);
		
		boton = new JButton("OK");
		boton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				VAviso.this.dispose();
			}
		});
		GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
		gbc_btnNewButton_1.gridx = 0;
		gbc_btnNewButton_1.gridy = 1;
		getContentPane().add(boton, gbc_btnNewButton_1);
		setModal(true);
	}

}
